﻿@model Tau.ViewModels.CategoryList

@{
    ViewBag.Title = "Index";
}

<div id="addEdit" title="Add/Edit Category" style="display:none"></div>

<h2>Categories &nbsp; &nbsp; <a href="#" class="addNew" onclick="popupAddEdit();" style="cursor:pointer"> + Add New Category</a></h2>



<div id="categoryList">
    @Html.Partial("CategoryList", Model)
</div>

<script type="text/javascript" charset="utf-8">

    function deleteCategory(categoryId, categoryName) {

        showYesNoDialog(
                        "Are you sure you want to delete this category (" + categoryName + ")?", 
                        function () {
                            location.href = '@Url.Action("Delete", "CategoryAdmin")' + '?categoryId=' + categoryId;
                        });
    }

    function popupAddEdit(editId) {

        var url = '@Url.Action("AddEditCategory", "CategoryAdmin")';

        if (editId != null && editId > 0) {
            url = url + "?categoryId=" + editId;
        }
        
        $("#addEdit").load(url, function () {

            $("#addEdit").dialog({
                autoOpen: true,
                height: 180,
                width: 350,
                modal: true
            });
        });
       
        
    }
        
</script>



